#include <stdio.h>
#include "../CppSQLite3.h"

int main(int argc, char **argv) {
  const char *sRoute = "test.db";  //设置sqlite数据库文件的路径

  CppSQLite3DB db;
  try
  {
    db.open(sRoute);  //打开数据库
    CppSQLite3Query q = db.execQuery("select * from table");  //执行查询
    for(int i = 0; i <= q.numFields() - 1; i++)  //遍历并打印表头
    {
      printf("%s\t", q.fieldName(i));
    }
    printf("\n");
    while(!q.eof())     //打印表
    {
      for(int i = 0; i<=q.numFields()-1; i++)
      {
        printf("%s\t", q.getStringField(i));
      }
      printf("\n");
      q.nextRow();
    }
  }
  catch(CppSQLite3Exception& e)
  {
    printf("%s",e.errorMessage());
  }
  db.close();
  printf("\n");
  return 0;
}
